<template>
	<view class="main">
		<view :style="'padding-top:'+(demo.height+demo.top+10)+'px'">
			<head1 class="nav_top"
				:style="'height:' +  demo.height + 'px;' + 'padding-top:' + demo.top + 'px;padding-bottom:10px'"
				:nav="title">
			</head1>
		</view>
		<view class="index_line"></view>
		<view class="form_main">
			<form action="">
				<view class="list" style="display: none;">
					<view :class="zixunForm.context==''?'activeTrue':'activeFalse'">
						<text style="color: red;">*</text><text>咨询标题</text>
					</view>
					<input type="text" value="" v-model="zixunForm.context" placeholder="请输入标题" />
					<view class="formline"></view>
				</view>
				<view class="list">
					<view class="list_tit">
						<text>咨询内容</text>
					</view>
					<textarea value="" v-model="zixunForm.dataText" placeholder="请输入你想要的咨询内容" />
				</view>
				<button class="btn" @click="submitForm(zixunForm)">提交</button>
			</form>
		</view>
	</view>
</template>

<script>
	import head1 from '../../common/head/head'
	export default {
		components: {
			head1
		},
		data() {
			return {
				title: '发布咨询',
				demo: {
					top: '',
					height: ''
				},
				zixunForm: {
					userId: '',
					noticeType: '103951',
					context: '',
					dataText: ''
				}
			}
		},
		computed: {
			// 获取store中存储的userId
			userId() {
				this.zixunForm.userId = this.$store.state.userId
			}
		},
		created() {
			const demo = uni.getMenuButtonBoundingClientRect()
			this.demo.top = demo.top
			this.demo.height = demo.height
		},
		methods: {
			submitForm(data) {
				if(data.dataText==''){
					uni.showToast({
						title:'请输入咨询内容',
						icon:'none'
					})
				}else{
					this.$myResquest.setZixun(data).then(res => {
						if (res.data.code == 200) {
							uni.showToast({
								title: "提交成功"
							})
							setTimeout(function(){
								uni.navigateBack()
							},1000)
						} else {
							uni.showToast({
								title: "提交失败",
								icon: "none"
							})
						}
					})
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.activeFalse {
		color: #000000;
	}

	.activeTrue {
		color: red;
	}

	.main {
		position: fixed;
		top: 0;
		z-index: 999;
		height: 100%;
		width: 100%;

		.form_main {
			background: #ffffff;
			padding: 40rpx 40rpx 0;
			box-sizing: border-box;
			width: 100%;
			height: 100%;

			form {
				display: flex;
				width: 100%;
				height: 100%;

				.list {
					margin-bottom: 72rpx;
					.list_tit{
						display: flex;
						font-size: 33rpx;
						font-family: Microsoft YaHei Bold, Microsoft YaHei Bold-Bold;
						font-weight: bold;
						text-align: left;
						color: #49b3af;
						    padding: 17rpx 0;
					}
					.tit {
						font-size: 28rpx;
						font-family: PingFang SC, PingFang SC-Medium;
						font-weight: 500;
						text-align: left;
						color: #333333;
						line-height: 36rpx;
						margin-bottom: 20rpx;
					}

					textarea {
						width: 664rpx;
						padding: 28rpx 14rpx;
						box-sizing: border-box;
						height: 412rpx;
						background: #f4f4f4;
						border-radius: 6rpx;

					}

					.formline {
						width: 670rpx;
						height: 2rpx;
						background: #e5e5e5;
						margin-top: 10rpx;
					}
				}

				.btn {

					width: 600rpx;
					height: 88rpx;
					background: #5cd1ce;
					border-radius: 44rpx;
					margin: 166rpx auto 0px;
					font-size: 34rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 500;
					text-align: center;
					color: #ffffff;
				}
			}
		}
	}
</style>
